package com.army.study.bean;

import com.army.study.utils.LogUtil;
import ohos.aafwk.content.IntentParams;

import java.util.List;

public class MailDataBean {

    private static final String ARGS_RECEIVER = "receiver";

    private static final String ARGS_CC = "cc";

    private static final String ARGS_TITLE = "title";

    private static final String ARGS_CONTENT = "content";

    private static final String ARGS_PIC_LIST = "pic_list";

    private String receiver;

    private String cc;

    private String title;

    private String content;

    private List<String> pictureDataList;

    public MailDataBean() {
        super();
    }

    public MailDataBean(String receiver, String cc, String title, String content) {
        super();
        this.receiver = receiver;
        this.cc = cc;
        this.title = title;
        this.content = content;
    }

    public MailDataBean(IntentParams params) {
        if (params == null) {
            LogUtil.info(this.getClass(), "Invalid intent params, can't create MailDataBean");
            return;
        }

        this.receiver = getStringParam(params, ARGS_RECEIVER);
        this.cc = getStringParam(params, ARGS_CC);
        this.title = getStringParam(params, ARGS_TITLE);
        this.content = getStringParam(params, ARGS_CONTENT);
        this.pictureDataList = (List<String>) params.getParam(ARGS_PIC_LIST);
    }

    private String getStringParam(IntentParams params, String key) {
        Object value = params.getParam(key);
        if (value != null && (value instanceof String)) {
            return (String)value;
        }
        return "";
    }

    public void saveDataToParams(IntentParams params) {
        params.setParam(ARGS_RECEIVER, this.receiver == null ? "" : this.receiver);
        params.setParam(ARGS_CC, this.cc == null ? "" : this.cc);
        params.setParam(ARGS_TITLE, this.title == null ? "" : this.title);
        params.setParam(ARGS_CONTENT, this.content == null ? "" : this.content);
        params.setParam(ARGS_PIC_LIST, this.pictureDataList == null ? null : this.pictureDataList);
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getCc() {
        return cc;
    }

    public void setCc(String cc) {
        this.cc = cc;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<String> getPictureDataList() {
        return pictureDataList;
    }

    public void setPictureDataList(List<String> pictureDataList) {
        this.pictureDataList = pictureDataList;
    }
}
